{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 用Python实现激活函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 安装相关的工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: pygal in c:\\anacondafile\\lib\\site-packages (2.4.0)\n",
      "Requirement already satisfied: numpy in c:\\anacondafile\\lib\\site-packages (1.19.2)\n",
      "Requirement already satisfied: matplotlib in c:\\anacondafile\\lib\\site-packages (3.3.2)\n",
      "Requirement already satisfied: certifi>=2020.06.20 in c:\\anacondafile\\lib\\site-packages (from matplotlib) (2020.6.20)\n",
      "Requirement already satisfied: pillow>=6.2.0 in c:\\anacondafile\\lib\\site-packages (from matplotlib) (8.0.1)\n",
      "Requirement already satisfied: cycler>=0.10 in c:\\anacondafile\\lib\\site-packages (from matplotlib) (0.10.0)\n",
      "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in c:\\anacondafile\\lib\\site-packages (from matplotlib) (2.4.7)\n",
      "Requirement already satisfied: numpy>=1.15 in c:\\anacondafile\\lib\\site-packages (from matplotlib) (1.19.2)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in c:\\anacondafile\\lib\\site-packages (from matplotlib) (1.3.0)\n",
      "Requirement already satisfied: python-dateutil>=2.1 in c:\\anacondafile\\lib\\site-packages (from matplotlib) (2.8.1)\n",
      "Requirement already satisfied: six in c:\\anacondafile\\lib\\site-packages (from cycler>=0.10->matplotlib) (1.15.0)\n",
      "Requirement already satisfied: pillow in c:\\anacondafile\\lib\\site-packages (8.0.1)\n"
     ]
    }
   ],
   "source": [
    "!pip install pygal\n",
    "!pip install numpy\n",
    "!pip install matplotlib\n",
    "!pip install pillow"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 导入绘图和数学计算工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现ReLU函数 其表达式为 $$ ReLU(x)=max(0,x) $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-5.         -4.8989899  -4.7979798  -4.6969697  -4.5959596  -4.49494949\n",
      " -4.39393939 -4.29292929 -4.19191919 -4.09090909 -3.98989899 -3.88888889\n",
      " -3.78787879 -3.68686869 -3.58585859 -3.48484848 -3.38383838 -3.28282828\n",
      " -3.18181818 -3.08080808 -2.97979798 -2.87878788 -2.77777778 -2.67676768\n",
      " -2.57575758 -2.47474747 -2.37373737 -2.27272727 -2.17171717 -2.07070707\n",
      " -1.96969697 -1.86868687 -1.76767677 -1.66666667 -1.56565657 -1.46464646\n",
      " -1.36363636 -1.26262626 -1.16161616 -1.06060606 -0.95959596 -0.85858586\n",
      " -0.75757576 -0.65656566 -0.55555556 -0.45454545 -0.35353535 -0.25252525\n",
      " -0.15151515 -0.05050505  0.05050505  0.15151515  0.25252525  0.35353535\n",
      "  0.45454545  0.55555556  0.65656566  0.75757576  0.85858586  0.95959596\n",
      "  1.06060606  1.16161616  1.26262626  1.36363636  1.46464646  1.56565657\n",
      "  1.66666667  1.76767677  1.86868687  1.96969697  2.07070707  2.17171717\n",
      "  2.27272727  2.37373737  2.47474747  2.57575758  2.67676768  2.77777778\n",
      "  2.87878788  2.97979798  3.08080808  3.18181818  3.28282828  3.38383838\n",
      "  3.48484848  3.58585859  3.68686869  3.78787879  3.88888889  3.98989899\n",
      "  4.09090909  4.19191919  4.29292929  4.39393939  4.49494949  4.5959596\n",
      "  4.6969697   4.7979798   4.8989899   5.        ]\n"
     ]
    }
   ],
   "source": [
    "y = np.linspace(-5,5,100)\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "relu = lambda x: np.maximum(x, 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x147768809d0>]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAahElEQVR4nO3deZzNdd/H8dfHjH1nJhVZSkram3RJe1mSFLMkJa1c0uJOly6td6q7xS3q0kJosc+CKCW5SKsaURFFQqiMfc0w873/GNyuwpzhnPM9y/v5eHg04/yc3/tIb99+53c+X3POISIikauU7wAiInJoKmoRkQinohYRiXAqahGRCKeiFhGJcImheNKkpCRXv379UDy1iEhMmjNnzlrnXPKBHgtJUdevX5/c3NxQPLWISEwys+UHe0yXPkREIpyKWkQkwqmoRUQinIpaRCTCqahFRCJcQHd9mNkyYAtQAOx2zqWEMpSIiPy/ktyed6lzbm3IkoiIRLHdhbsBSCwV/LuedelDRCQIHpz+IC1HtOT3rb8H/bkDrX4HfGBmDhjsnBvy5wPMrCvQFaBu3brBSygiEuEmLppIv8/6kWAJLF6/mFqVagX1+QNdUTd3zp0NXAn0MLOL/nyAc26Icy7FOZeSnHzAT0GKiMScJeuX0GViFwCeueIZLqh7QdDPEVBRO+dW7/nnGmAC0DToSUREosyOXTtIy0xj887NtD+5Pb2a9QrJeYotajOraGaV934NtATmhySNiEgU6TGlB9/8/g0NazTk9Wtex8xCcp5ArlHXAibsCZAIjHbOvR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M+pnZIjP71swmmFk135lCId42aDaz48xshpktNLMFZnav70zhYmYJZjbXzN7xnSVYVNR/YmbHUbSR7wrfWcJkGnCqc+504Eegj+c8QbffBs1XAqcA15vZKX5ThdxuoJdzrjHwN6BHHLzmve4FFvoOEUwq6r8aAPTmANuNxSLn3AfOud17vv2Coh18Ys2+DZqdc/nA3g2aY5Zz7lfn3Nd7vt5CUXHV9psq9MysDnAVMNR3lmBSUe/HzNoBq5xz3/jO4smtwHu+Q4TAgTZojvnS2svM6gNnAbM9RwmHgRQttAo95wiqgDYOiCVm9iFw9AEeegh4EGgZ3kShd6jX7Jx7e88xD1H0v8ujwpktTALaoDkWmVklIAfo6Zzb7DtPKJlZW2CNc26OmV3iOU5QxV1RO+euONDPm9lpQAPgGzODoksAX5tZU+fcb2GMGHQHe817mVkXoC1wuYvNG+vjcoNmMytNUUmPcs6N950nDJoD7cysDVAOqGJmI51zN3rOdcT0gZeDMLNlQIpzLtomcJWImbUGngcuds7l+c4TCmaWSNEbpZcDqyjasLlTLO/9aUWrjTeB9c65np7jhN2eFfX9zrm2nqMEha5RyyCgMjDNzOaZ2au+AwXbnjdL927QvBDIjOWS3qM50Bm4bM+/13l7VpoShbSiFhGJcFpRi4hEOBW1iEiEU1GLiEQ4FbWISIRTUYuIRDgVtYhIhFNRi4hEuP8DwgHLEA+tlb0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(y, relu(y), color='green', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现PReLU函数 其表达式为 $$  PReLU(x_i)= \\begin{cases} x_i, &\\text{if }x_i\\text{ >0}\\\\ a_ix_i, &\\text{if } x_i\\leqslant0     \\end{cases} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x14776930520>]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAYe0lEQVR4nO3deZRV9Znu8e8rg4wKgVKGKiQxRq+dKDElN93Ga9ToMpE4YYw44YhGTSPigNLGtm2yMBiJbUAkoKKCtkEwWtoaNejVmHAtEBWCUxNAJilEGZSpqt77x4/qQqjhFJx9fvuc83zWqlX7WGfteg6ynrXZ+7ffbe6OiIik116xA4iISNNU1CIiKaeiFhFJORW1iEjKqahFRFKudRI77d69u/ft2zeJXYuIFKQ5c+ascfeShn6WSFH37duXysrKJHYtIlKQzGxJYz/TqQ8RkZRTUYuIpJyKWkQk5VTUIiIpp6IWEUm5jFZ9mNliYANQA1S7e3mSoUREpF5Llucd6+5rEksiIpLHamuhuhrats3+vnXqQ0QkC0aOhBNOgDUJHM5mWtQO/NHM5pjZkIbeYGZDzKzSzCqrqqqyl1BEJOUeeABGj4Y//xnmz8/+/jMt6qPc/Qjgh8BVZvZ/dn6Du09093J3Ly8pafAuSBGRgvPKK3D55WF73Dj4/vez/zsyKmp3X7H9+2pgJtA/+1FERPLLBx/AGWfAtm0wbFh9YWdbs0VtZh3NrHPdNnAikMDBvYhI/li7Fk4+OXwfMADGjEnud2Wy6mN/YKaZ1b1/mrs/l1wkEZF027oVzjwzHFEfdhhMmwatWiX3+5otandfBByeXAQRkfzhDldeCbNmQY8eUFEBnTsn+zu1PE9EpAXuvBMmT4Z27eCpp6CsLPnfqaIWEcnQk0/CjTeG7YcfhiOPzM3vVVGLiGRg7lw499xw6mPUqHCOOldU1CIizVi+HH78Y/jiC7jgArjpptz+fhW1iEgTPv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},
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "x = np.linspace(-5,5,100)\n",
    "pr = lambda xs: [x*0.1 if x <0 else x for x in xs] \n",
    "plt.plot(x, pr(x), color='blue', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现softplus函数 其表达式为 $$ softplus(x)= log{(1+e^x)} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1c0166d8e80>]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWoAAAD4CAYAAADFAawfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAZfklEQVR4nO3deZRU9Z3+8fcHaHYQjQ0iy6CGIUoEHYlGyeT3AxVBOC6oEXdjIhOXuEcUEwnuB0WNmonpIAgiEkFQJO5RTHRUdhDBIBoUF2QLi7RKN3znjw89zdLQ1U1VfW9VPa9z7qlb3W330y6Pl3u/i4UQEBGR5KoTO4CIiOyeilpEJOFU1CIiCaeiFhFJOBW1iEjC1cvEN913331Dhw4dMvGtRUTy0qxZs1aFEIqr+lxGirpDhw7MnDkzE99aRCQvmdnHu/qcbn2IiCScilpEJOFU1CIiCaeiFhFJOBW1iEjCpTTqw8yWAhuAzUB5CKFbJkOJiEilmgzP6xFCWJWxJCIiOay83F/rZWDQs259iIikwU03Qa9e8OWX6f/eqXZ/AF4yswD8MYRQkv4oIiK5afJkGDYM6taFDz6AVq3S+/1TLeruIYTPzawl8LKZvR9C+Nu2X2BmA4GBAO3bt09vShG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/BC4rgN+5wpXAotgh0klFvbP7gOupYruxfBRCeCmEUL717dv4Dj755v82aA4hbAIqNmjOWyGEL0IIs7eeb8CLq03cVJlnZm2BvsCI2FnSSUW9DTM7CfgshDAvdpZILgKejx0iA6raoDnvS6uCmXUADgfeiRwlG+7HL7S2RM6RViltHJBPzOwVYL8qPnUTMBjold1Embe73zmE8MzWr7kJ/+Py49nMliUpbdCcj8ysKfAUcFUIYX3sPJlkZv2AFSGEWWb2/yPHSauCK+oQwnFVfdzMDgUOAOaZGfgtgNlmdmQIYXkWI6bdrn7nCmZ2AdAPODbk58D6gtyg2cyK8JJ+PIQwKXaeLOgOnGRmJwINgeZmNjaEcG7kXHtME152wcyWAt1CCLm2AleNmFlv4F7g/4UQVsbOkwlmVg9/UHos8Bm+YfPZ+bz3p/nVxmhgTQjhqshxsm7rFfV1IYR+kaOkhe5Ry0NAM+BlM5trZg/HDpRuWx+WVmzQvAh4Mp9LeqvuwHlAz63/XOduvdKUHKQrahGRhNMVtYhIwqmoRUQSTkUtIpJwKmoRkYRTUYuIJJyKWkQk4VTUIiIJ979KOUJRF5lSRwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "x = np.linspace(-5,5,100)\n",
    "softplus = lambda x: np.log(1.0 + np.exp(x))\n",
    "plt.plot(x, softplus(x), color='blue', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现sigmoid函数 其表达式为 $$  sigmoid(x)= \\frac{1}{1+e^{-x}} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1c01672cee0>]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "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KLqG7+b9s99H/htPod5tWOAHwLfrf5v+051z1VykHroIiJ5Qj10EZE8oUAXEckTCnQRkTyhQBcRyRMKdBGRPKFAFxHJEwp0EZE88f8efSHGKtjYGAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.linspace(-5,5,100)\n",
    "sigmoid = lambda x: 1 / (1 + np.exp(-x))\n",
    "plt.plot(x,sigmoid(x), color='red', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现饱和S函数 其表达式为 $$   S(x)= \\begin{cases} 0, &\\text{if }x\\text{ <0}\\\\ 1, &\\text{if } x\\geq0     \\end{cases}  $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x14776a2c940>]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAPTklEQVR4nO3df6zdd13H8eeLOxZjNhyxF4X+sP2jKI2C4nUQwDBFoB2ExsQ/NhR0Spolm4FEIlWi/kH4gxCVEDaahgwkGhcJUyopTkxU/iAz7XAMyhy5DNkuxawTgwQCTdu3f5xv8ct3p72n3fnB5/T5SE7O/f64575P9u0z3517zv2mqpAkte9pix5AkjQdBl2SloRBl6QlYdAlaUkYdElaElct6gdv2bKldu7cuagfL0lNuv/++5+oqtVx2xYW9J07d3L8+PFF/XhJalKSr1xomy+5SNKSMOiStCQMuiQtCYMu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PDTVfV84IvAHyx4npnoXRB9H7AHuDnJnsVONXNngN+rqucBLwZuuwKe83lvBh5a9BDTZNAv358Dv8+YS+0tm6r6x6o60y3ex+iKVMvoexdEr6rTwPkLoi+tqvpaVX2m+/qbjAK3dbFTzV6SbcBrgA8sepZpMuiXIcnrgK9W1WcXPcsC/DbwiUUPMSMXutj5FSHJTuDngH9b8Cjz8B5GJ2TnFjzHVE10gYsrUZJ/An58zKa3A38IvGq+E83WxZ5vVX2s2+ftjP4X/a/mOdscTXSx82WU5Brgo8Bbqup/Fz3PLCV5LfB4Vd2f5IYFjzNVBv0CqupXxq1P8jPALuCzSWD08sNnklxfVf81xxGn6kLP97wkvwm8FnhFLe+HF67Ii50neTqjmP9VVd2z6Hnm4KXA65LcCPwQ8Iwkf1lVv7HguZ4yP1j0FCX5T2Ctqlr8q20TSbIX+DPg5VV1atHzzEqSqxj90vcVwFcZXSD99VV1YqGDzVBGZyV/AXy9qt6y4HHmrjtDf2tVvXbBo0yFr6FrEu8DrgU+meSBJIc2+4YWdb/4PX9B9IeAv1nmmHdeCrwB+OXuv+0D3ZmrGuQZuiQtCc/QJWlJGHRJWhIGXZKWhEGXpCVh0CVpSRh0SVoSBl2SlsT/ATLEnOw+C88eAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.linspace(-5,5,100)\n",
    "pr = lambda xs: [0 if x <0 else 1 for x in xs] \n",
    "plt.plot(x, pr(x), color='blue', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现logit函数 其表达式为 $$  logit(x)= log{\\frac{x}{1-x}} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-12-99a8e99dfe48>:2: RuntimeWarning: invalid value encountered in log\n",
      "  logit = lambda x: np.log(x / (1 - x))\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1c01678d280>]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAD4CAYAAAAJmJb0AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAbWklEQVR4nO3de3xU1bn/8c8DgojQKoKCIjfvSG3RVNFTLUK9ICpaVFARATGiVWmPWGrxaH8tWu+gtQg5QRHl0iIqgnjBI5b2eKwGqoiCHhURlGoEvEERSdbvjyeeICZkktkze2bP9/165eXMzmTP436RL4s1z17LQgiIiEgyNYq7ABERyRyFvIhIginkRUQSTCEvIpJgCnkRkQTbKY43bd26dejUqVMcby0ikrcWL178cQihTX1+JpaQ79SpE2VlZXG8tYhI3jKzVfX9GU3XiIgkmEJeRCTBFPIiIgmmkBcRSTCFvIhIginkRUQSTCEvIpIlX36Z/fdUyIuIZMHixdClCzz5ZHbfVyEvIpJhGzbA2WfDBx/Ao49m970V8iIiGVRZCRdeCCtXwuGHw/jx2X1/hbyISAbddhvMnQu77QYPPQTNmmX3/dMOeTNrZmYvmtkrZvaamf2/KAoTEcl3ixbBr3/tj++/Hzp3zn4NUSxQ9iXQK4TwhZk1Af5mZk+EEF6I4NwiInnpn/+EAQOgogJGj4bTT4+njrRDPvhO4F9UPW1S9aXdwUWkYG3dCued50F/3HEwdmx8tUQyJ29mjc3sZeAjYEEI4e81vKbYzMrMrKy8vDyKtxURyUnXXw8LF8Jee8HMmbBTLIu6u0hCPoRQEUL4AdAeONLMutXwmpIQQlEIoahNm3qteS8ikjcefxxuvBEaNYIZM6Bdu3jribS7JoTwCfAccHKU5xURyQfvvgsXXOCP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+Pu+64rsU2r3sWmA+cFXfdMf652A14HehQ9XzPuOuO8Vr8Gri56nEbYD3QNO7aM3AtjgMOB5bV8v1TgCcAA3qkmhUayWfWkcBbIYR3QghbgJlAv21fEEJ4PoSwoerpC0D7LNeYLXVeiypXALOBj7JZXJalci3OAx4OIbwHEEJI6vVI5VoEoKWZGdACD/mt2S0z80IIi/D/t9r0A6YG9wKwm5m1q+u8CvnM2gdYvc3zNVXHanMR/jd1EtV5LcxsH+BMYGIW64pDKn8uDgR2N7PnzGyxmQ3OWnXZlcq1uBs4BPgAeBUYGUKozE55OaW+eQJEsMer7JDVcKzGnlUzOx4P+R9ltKL4pHItxgOjQwgVPmhLrFSuxU7AEUBvYBfgf8zshRDCm5kuLstSuRYnAS8DvYD9gAVm9tcQwmcZri3XpJwn21LIZ9YaYN9tnrfHRyPfYGaHAaVAnxDCuizVlm2pXIsiYGZVwLcGTjGzrSGER7NSYfakci3WAB+HEDYCG81sEfB9IGkhn8q1GArcFHxi+i0zWwkcDLyYnRJzRkp5sj1N12TWS8ABZtbZzJoCA4HHtn2BmXUAHgYuSOAobVt1XosQQucQQqcQQifgIeCyBAY8pHAtgDnAsWa2k5k1B44Clme5zmxI5Vq8h/+LBjPbCzgIeCerVeaGx4DBVV02PYBPQwhr6/ohjeQzKISw1cwuB57CuwjuDSG8ZmYjqr4/EbgO2AOYUDWC3RoSuPJeiteiIKRyLUIIy83sSWApvr1maQihxta6fJbin4vfAVPM7FV8ymJ0CCFxSxCb2QygJ9DazNYA1wNN4P+uw3y8w+YtYBP+L5y6z1vVmiMiIgmk6RoRkQRTyIuIJJhCXkQkwRTyIiIJppAXEUkwhbyISIIp5EVEEuz/A3ed4qiNhbEWAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "aa = np.linspace(-5,5,100)\n",
    "logit = lambda x: np.log(x / (1 - x))\n",
    "plt.plot(aa,logit(aa), color='blue', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现softsign函数 其表达式为 $$   softsign(x)= \\frac{x}{1+\\lvert x\\rvert} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x147767a38b0>]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAe8UlEQVR4nO3deZQU5bnH8e/DACqCCwrIMiwqIGoEsV3RuAGCUTHuRgVjDNEr0SQaNW43ifcet2iM0WjQeIJGJfcqCgFElogLijIssisjsiMOy1UEA8zw3D/entAOM8MM3TPV3fX7nFOnlq7qeUaH/nW9VfW+5u6IiEh8NYi6ABERiZaCQEQk5hQEIiIxpyAQEYk5BYGISMw1jLqA3XHggQd6x44doy5DRCSnTJ8+fa27t6i4PSeDoGPHjhQVFUVdhohITjGzpZVtV9OQiEjMKQhERGJOQSAiEnMKAhGRmFMQiIjEnIJARCTmFAQiIjGXk88RiIjkq+3boaQEli2DFStg+fIwL18eNAiuvTazP1NBICJSj8rKwof6kiU7pqVLw7RsWfiw37Kl6uN79sx8TQoCEZEM++orKC6GTz8N0+LFYfrss/BhX1pa/fHNm0NhIbRvH+aFhdCuXZg6d858vQoCEZHdsHkzLFoEn3yyYyouDttKSqo/tnVr6NQJOnSAjh3DvHwqLISmTevlV/g3BYGISDXWroX588O0YAEsXBimZcuqPmbPPeGQQ3ZMBx+8Y96hQ3g9mygIRESAjRthzhyYOzdMc+bAvHlVf7tv2B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ewFXAGcn/t7OS35Ylx+iMQEQk5nRGICIScwoCEZGYUxCIiMScgkBEJOYUBCIiMacgEBGJOQWBiEjM/T8QHmVpVzHaxgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.linspace(-5,5,100)\n",
    "softsign = lambda x: x / (1 + np.absolute(x))\n",
    "plt.plot(x,softsign(x), color='blue', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现tanh函数 其表达式为 $$  tanh(x)= \\frac{e^x-e^{-x}}{e^x+e^{-x}} $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x14777d8c9a0>]"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAe50lEQVR4nO3deZhU5Zn38e9tQ4OiIGiL7DCvuMUoxh7corihQBTUiFuixKjoOyEaJ5tvGI2O44yamMWESMBgmMhoTASbUVyAGJdElIYoggZZxBfsFhpEERCh6Xv+eE4PZVG9Ucup5fe5rnPVc7aquwypX5/nLI+5OyIiUrr2irsAERGJl4JARKTEKQhEREqcgkBEpMQpCERESly7uAvYEwceeKD3798/7jJERArKggUL1rt7RfLyggyC/v37U11dHXcZIiIFxczeTbVcXUMiIiVOQSAiUuIUBCIiJU5BICJS4hQEIiIlLiNBYGZTzGydmS1uYr2Z2X1mttzMFpnZFxLWDTOzpdG6mzNRj4iItF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AD4OzcVpR9zX1nd6+KthlP6EqYlsvacshSLCuJoz4z2xd4DPiWu2+Ku55sMbNzgXXuvsDMTou5nIxSEGSYu5+VarmZfR4YALxuZhC6SBaa2WB3fz+HJWZcU9+5kZmNAc4FzvTivXFlDdAnYb43UBNTLTljZu0JITDN3afHXU+WnQyMNLMRQEegs5k95O5fjbmutOmGspiY2Sqg0t0L8QmGrWZmw4CfAEPcvS7uerLFzNoRToafCbwHzAcuTxifu+hY+ItmKvCBu38r5nJyKjoi+I67nxtzKRmhcwSSbb8E9gNmm9lrZjYx7oKyITohPg54hnDS9NFiDoHIycAVwBnR/7avRX8tS4HREYGISInTEYGISIlTEIiIlDgFgYhIiVMQiIiUOAWBiEiJUxCIiJQ4BYGISIn7H6fTpE3nQOnXAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.linspace(-5,5,100)\n",
    "th = lambda x: np.tanh(x)\n",
    "plt.plot(x,th(x), color='blue', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现hard tanh函数 其表达式为 $$  hard tanh(x)= \\begin{cases} -1, &\\text{if }x\\text{ <-1}\\\\ 1, &\\text{if } x\\text{ >1}\\\\ x,&\\text{otherwise }  \\end{cases}   $$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x14777df2130>]"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIW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MEzgEOZV1ECxXt/YLfc1Hk9T1fGBHjqzfmMgjySlJ3rU/sO1XR3i/4PRdFp71nTw2ZmRWcg8DMrOAcBK21KusCWqxo7xf8nouio96zPyMwMys4nxGYmRWcg8DMrOAcBBmQ9BeSQlLHPy9N0rckvShpq6QHJI3NuqZmkTRf0i5JPekzuDuapMmSfippp6Ttkr6adU2tIGmUpOckPZx1LY3iIGgxSZNJWm6/lnUtLbIO+M8RcSnwEvDfMq6nKSSNAlYAC4AZwO2SZmRbVdMdBf48In4fuBK4swDvGeCrJC31O4aDoPW+A3yTETyuM48i4vH0mRQAz5A8oa4TzQZ6ImJPRBwB7gcWZVxTU0XE/ojYnC7/luSX48Rsq2ouSZOAm4HvZ11LIzkIWkjSbcDrEfF81rVk5E+BR7MuokkmAnsr1nvp8F+KlSRNBS4Dns24lGb7nyR/yB3PuI6GGvSZxTY8ktYD59fYdRfwl8BNra2o+QZ6zxHxYDrmLpKphPtaWVsLqca2Qpz1STod+BHwtYh4J+t6mkXSLcDBiNgk6fqMy2koB0GDRcSNtbZLugSYBjwvCZIpks2SZkfEGy0sseH6e89lkpYAtwBzo3NvXOkFJlesTwL2ZVRLy0g6hSQE7ouIH2ddT5NdBdwmaSHwEeBjkv5fRHwh47rq5hvKMiLpFaAUEXnsYDhkkuYD3waui4i+rOtpFkmjST4Mnwu8DmwEPl/xfO6Oo+QvmtXAWxHxtYzLaan0jOAvIuKWjEtpCH9GYM32v4EzgHWStkhamXVBzZB+IL4MWEvyoek/d3IIpK4CvgjckP633ZL+tWw54zMCM7OC8xmBmVnBOQjMzArOQWBmVnAOAjOzgnMQmJkVnIPAzKzgHARmZgX3/wEZgrYqTXkDcwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "def hard_tanh(x):\n",
    "    if abs(x)<1:\n",
    "        return x\n",
    "    else:\n",
    "        if x>1: \n",
    "            return 1\n",
    "        else:\n",
    "            return -1\n",
    "x = np.linspace(-5,5,100)\n",
    "htan = lambda xs: [hard_tanh(x) for x in xs] \n",
    "plt.plot(x,htan(x), color='blue', lw=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 实现softmax函数 其表达式为 $$  softmax(x)= \\frac{e^{zm}}{\\sum_{k}{e^{zk}}}$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1c0167dad30>]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAef0lEQVR4nO3de3zcdZ3v8ddnJklzbUubpPdr6BWBQkNBLnJpq0V4WDzqWlDRPSriipfdx1mXc9bds7r78OhZdx/6eID2lIIrrIKK4sJuFRsuUgS0KXcybUnTlqalk6S3NGnTJDOf80cmdTqk7aSd5DczeT8fjzwyv/l98/u9reHdX7/zu5i7IyIiuS8UdAAREckMFbqISJ5QoYuI5AkVuohInlChi4jkiYKgdlxZWekzZ84MavciIjlp06ZNbe5eNdC6wAp95syZ1NfXB7V7EZGcZGY7T7ZOUy4iInlChS4ikidU6CIieUKFLiKSJ1ToIiJ5QoUuIpInVOgiInlChS4iMoy+V/cmz21rG5Jtq9BFRIZJy+EuvvvEVup3HBiS7avQRUSGyZORFtxh2YIJQ7J9FbqIyDCpi0SZMraEBZMqhmT7KnQRkWFwtDvGhjfbWLagGjMbkn2o0EVEhsGzjW0c642zfOHEIduHCl1EZBjUNUSpGFXAklnjhmwfKnQRkSEWjztPbI5y9bwqig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LP3f9gZg8DLwK9wEtk+BYAOXXaooiInFyuTbmIiMhJqNBFRPKECl1EJE+o0EVE8oQKXUQkT6jQRUTyhApdRCRP/H+3w8v3maUCrQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import math\n",
    "w=[1,2,3,4,5,6,7,8,9]\n",
    "w_exp=[math.exp(i) for i in w]\n",
    "# print(w_exp)\n",
    "sum_w_exp = sum(w_exp)\n",
    "softmax = [round(i / sum_w_exp, 3) for i in w_exp]\n",
    "# print(softmax)\n",
    "#print(sum(softmax))\n",
    "plt.plot(softmax)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
